/*
 * Created on Jun 24, 2005
 *
 */
package com.erclab.internal.xpresso.unittests;

import com.erclab.internal.xpresso.Application;
import com.erclab.internal.xpresso.conf.Settings;
import com.erclab.internal.xpresso.exceptions.ApplicationException;
import com.erclab.internal.xpresso.exceptions.DirectoryException;
import com.erclab.internal.xpresso.exceptions.ObjectCreatorException;
import com.erclab.internal.xpresso.security.User;
import com.erclab.internal.xpresso.util.MysqlObjectCreator;

import junit.framework.TestCase;

/**
 * @author Enrique Rodriguez.
 *
 */
public class ObjectCreatorTest extends TestCase {

	Application xpresso = null;
	User user = null;


	/**
	 * Constructor for ObjectCreator.
	 * @param arg0
	 */
	public ObjectCreatorTest(String arg0) {
		super(arg0);
	}


	protected void setUp() throws Exception {
		super.setUp();
		try {
			xpresso = new Application();
		} catch(ApplicationException e){
			fail("Create Application failed: " + e.toString());
		}
		try {
			user = new User();
			Settings.getUserDirectory().loadUserBean(user);
		} catch (DirectoryException e) {
			fail();
			e.printStackTrace();
		}
	}

	public void testCreateForm(){
		MysqlObjectCreator oc = new MysqlObjectCreator();
		try {
			oc.createForm("Test", "App_forms", "IdForm", "IdForm", 1, 1);
		} catch (ObjectCreatorException e) {
			e.printStackTrace();
			fail();
		}
	}
	
	public void testCreateReport(){
		MysqlObjectCreator oc = new MysqlObjectCreator();
		try {
			oc.createReport("ReportTest", "reportfilters", "SELECT * FROM reportfilters",
							"IdFilter", 1, 1);
		} catch (ObjectCreatorException e) {
			e.printStackTrace();
			fail();
		}
	}

}
